Repository navigation
feat(manifest): generate Socket facts with Coana - #1726
Jeppe Fredsgaard Blaabjerg (jfblaa) wants to merge 11 commits into
Conversation
34c53a1 to
2429c74
Compare
PR SummaryHigh Risk Overview Facts placement and fix/reach sidecars change materially. Builds write into a caller-owned work dir; kept runs are copied to their target paths via Recursive manifest walk behavior is tightened: project membership uses absolute Reviewed by Cursor Bugbot for commit c681bbc. Configure here. |
2429c74 to
c681bbc
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 3 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit c681bbc. Configure here.
| factsPath: result.factsPath, | ||
| projects: result.projects, | ||
| sidecarEntry: result.sidecarEntry, | ||
| targetPath: result.targetPath, |
There was a problem hiding this comment.
Facts file not verified after Coana
Medium Severity
runManifestFacts treats Coana status: 'generated' as success without checking that factsPath exists. This command used to write the facts file itself; now Coana may exit 0 without producing it. keepFacts then copyFiles a missing path and throws, so the walk dies instead of failing closed with a clear error.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit c681bbc. Configure here.
There was a problem hiding this comment.
[agent] Not changing: Coana writes the facts file before it reports generated (generateRootFacts in coana-tech/coana-package-manager#2778, generate.ts#L281-L283), and minimumVersion keeps socket-cli on a Coana that does. A missing file would be a Coana bug, not a build outcome, so socket-cli doesn't check for it again.
| // project, OOM, plugin error), not an unresolved dependency, so it fails | ||
| // regardless of `ignoreUnresolved` — that flag only tolerates dependencies a | ||
| // successful run couldn't resolve. | ||
| return result.status === 'listed' ? result.projects : undefined |
There was a problem hiding this comment.
Empty project listing treated as success
Medium Severity
listBuildProjects accepts status: 'listed' with an empty projects array. The old enumerator treated zero records as “the task never ran,” because every real Gradle, Maven, or sbt build reports at least its root. A skipped build that listed nothing now looks loaded, so its modules are not skipped with it.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit c681bbc. Configure here.
There was a problem hiding this comment.
[agent] Not changing: the zero-projects rule moved into Coana with the enumerator. listRootProjects (coana-tech/coana-package-manager#2778, generate.ts#L160-L166) returns failed when the build reports no projects or no root, so listed always has at least the root and socket-cli doesn't check it twice.
| dir: path.join(manifestTmpDir, 'socket-facts-work'), | ||
| entries: new Map(), | ||
| withFiles: true, | ||
| } |
There was a problem hiding this comment.
Work directory never created before Coana
Medium Severity
socket scan create --reach and socket fix pass Coana a --work-dir that is never created. socket scan reach uses withTmpDir so the directory exists. If Coana requires that path the way it requires the --output-file parent, facts generation fails only on those two commands.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit c681bbc. Configure here.
There was a problem hiding this comment.
[agent] Not changing: Coana creates it. generate-socket-facts makes each build's state dir under --work-dir with mkdir(stateDir, { recursive: true }) (coana-tech/coana-package-manager#2778, cli-generate-socket-facts.ts#L94-L95), which creates the work dir too. Unlike --output-file, whose parent Coana does not create, nothing needs it to exist beforehand.
There was a problem hiding this comment.
[agent] Fixed in 910bb44 - on reflection socket-cli should own the work dir from start to end: socket scan create --reach and socket fix now create it before Coana runs, as socket scan reach and the recursive manifests already did, and their temporary directories still delete it. Coana creating it as well no longer matters.
137b184 to
aa44bb9
Compare
858ae3f to
dee38ba
Compare
dee38ba to
b8e363a
Compare
3d2cf42 to
1e5df23
Compare
socket-cli now asks `coana generate-socket-facts` for each build root instead of running its own build-tool scripts, and lists a build's projects and a .NET solution's members through the same command. - Coana writes a root's facts into its state dir under --work-dir and names where they belong. The walk always generates into a work dir, its own when no later Coana run reads one, and copies the facts of the roots it keeps to their target at the end; a dropped run never touches the file there. This replaces the save/restore of predicted facts files. - The kept roots' sidecar entries go to reachability and socket fix as --socket-facts-sidecar. - --auto-manifest builds through the same settings as the walk. Maven builds pom.xml by name, so its facts and state stay apart from a Gradle build in the same directory, and a --file in mavenOpts becomes the POM it builds instead of a build option. - A --reach-version or --fix-version older than the pinned Coana fails facts generation with a message naming that version. - The standalone build's README says every Coana use needs SOCKET_CLI_COANA_LOCAL_PATH.
1e5df23 to
a4c3b56
Compare
Martin Torp (mtorp)
left a comment
There was a problem hiding this comment.
The standalone distribution needs Coana’s facts component, and auto-manifest needs to preserve Maven’s working directory and arguments. I left the two cases inline along with the source-comment findings. The wording suggestions are nits.
| const requestFile = path.join(tmpDir, 'request.json') | ||
| const resultFile = path.join(tmpDir, 'result.json') | ||
| await fs.writeFile(requestFile, JSON.stringify(request), 'utf8') | ||
| const spawned = await spawnCoana( |
There was a problem hiding this comment.
ERR-01 This call also runs in the standalone CLI. That build bundles Coana’s cli and analyzers components, then sets REPOS_PATH to the analyzers directory. Coana 15.15.4 ships the JVM facts executable and .NET facts DLL in a third component, facts. With REPOS_PATH set, Coana looks there and skips the component download. A standalone build with embedded Coana therefore has neither helper.
Could we bundle and verify facts as well, then run the native manifest dotnet smoke test with embedded Coana, a clean cache and the network disabled? The green Linux PR job exercised the path for a build without Coana. Standalone launcher · Coana release layout · Linux job
| verbose: Boolean(sockJson.defaults?.manifest?.maven?.verbose), | ||
| withFiles: computeArtifactsSidecar, | ||
| const config = resolveEcosystemConfig('maven', cwd, sockJson) | ||
| await generateFacts('maven', mavenRoot(cwd, config.mavenFile), { |
There was a problem hiding this comment.
POLA-01 Moving Maven into the selected POM’s directory also moves the base for its other relative arguments. I checked -f sub/pom.xml -s settings.xml offline with the settings file at the repository root. Maven succeeded from the root and failed from sub, where it looked for sub/settings.xml. A trailing --file loses its missing-argument error and the CLI can produce facts for the root POM.
Could auto-manifest keep the original working directory and forward the original Maven arguments, as socket manifest maven does? Both cases would make good regression tests. The recursive walk can still select each POM explicitly.
| path.join(reactorA, 'pom.xml.socket.facts.json'), | ||
| ]) | ||
| // The restored file is not this scan's, so it is not to be collected. | ||
| // The file there is not this scan's, so it is not to be collected. |
There was a problem hiding this comment.
CMT-01 The assertion below excludes the committed file only when builtAlone is true. In the other discovery order the file still exists, but the test expects no discarded path. Could this comment say that the scan excludes the old file when it discards an independent build of the module?
| tmpDir, | ||
| toolOpts: buildOpts, | ||
| withFiles, | ||
| // The projects a dotnet solution builds; undefined when the SDK cannot read |
There was a problem hiding this comment.
CMT-02 The documented return values matter to the caller. Coana returns {status: "failed"} if listing crashes. With no members field, this function returns undefined, the same value as an explicit members: null from an unreadable solution. A readable sibling can then cause the crashed solution to be skipped. Could we check the status first, reserve the sibling fallback for the explicit unreadable result, and document those two cases? Coana failure response
| * - spawnCoana: runs cli-wrapper.mjs from the cache with the caller's args, | ||
| * cwd and environment, sets the variables Coana reads, leaves the user's | ||
| * API token variables out, and surfaces a failing run's output. | ||
| * - spawnCoana with a minimum version: refuses an older Coana. |
There was a problem hiding this comment.
CMT-03 Nit, could we drop this new coverage bullet? The test name already says that an older resolved Coana release is refused.
| let cwd = '' | ||
| let calls: Call[] = [] | ||
|
|
||
| // Answers each Coana run by writing `text` as its result file, or nothing when |
There was a problem hiding this comment.
CMT-21 Nit, could we drop this walkthrough? The write and its guard are visible in the mock. If the destination needs to stand out, coanaWritesResultFile would make it visible at the call site too.
| }) | ||
| } | ||
|
|
||
| // Answers each Coana run with `result`, as `coana generate-socket-facts` writes |
There was a problem hiding this comment.
CMT-22 Nit, could we drop this comment? The single call to coanaWrites directly below shows both the JSON conversion and what happens for undefined.
| manifestFiles: [{ file: `${subprojectDir}/pom.xml` }], | ||
| children: [], | ||
| } | ||
| // A Maven project of the build at `buildRoot`, loaded from `pomFile`. |
There was a problem hiding this comment.
CMT-23 Nit, could we call the helper mavenProject and drop this line? That gives readers the same context at each test call site.
| await setupRecursiveManifestConfig(repo, false) | ||
|
|
||
| expect(attempts).toBe(2) | ||
| // A listing's remedies point at this wizard, not at flags. |
There was a problem hiding this comment.
CMT-24 Nit, the assertion below already identifies which setup command the remedy should name. Could we drop the comparison with flags here?
| * The directory of the Coana CLI's `cli` component for `versionSpec`, an exact | ||
| * version or a range, downloading it into the cache when the cache lacks it. | ||
| * `env` reaches the cache script, which reads `XDG_CACHE_HOME` from it. | ||
| * version or a range, and the version it holds, downloading it into the cache |
There was a problem hiding this comment.
CMT-25 Nit, the added phrase about which version the directory holds repeats the version field in CoanaCliDir just above. Could we trim that phrase and keep the detail about how the cache gets XDG_CACHE_HOME?
|
Regarding the review below: Jeppe Fredsgaard Blaabjerg (@jfblaa) Martin Torp (@mtorp) We need to revert the PR that bundles |
The standalone build now stages Coana's `facts` component beside `cli` and `analyzers`, verified by the same size and sha256 checks, and installs all three in the Coana cache before Coana runs. Coana finds each component it needs there by version, so socket-cli no longer sets REPOS_PATH, which pointed Coana at the analyzers alone and kept it from finding its facts tools. The staging and VFS smoke checks no longer expect a repos/ directory inside the analyzers component, whose archive root is the repos layout.
Maven resolves relative arguments such as `--settings` and `--file` from the directory it starts in, and reports a `--file` without its argument. Auto-manifest moved Maven into the directory of the POM a `--file` in mavenOpts named and dropped the option, which broke both. It now runs Maven in the scan root with mavenOpts as written, as `socket manifest maven` does. The recursive walk still builds each POM by its own file and ignores a `--file`.
A crashed `--list-members` run answers `status: failed` with no members, which read as the SDK being unable to read the solution, so a readable twin beside it could skip it. Only `members: null` means that now; a failed listing lists nothing and the solution is built.
getCoanaCliDir's doc again says it returns the version it resolved, and the test header again lists the minimum-version tests, plus the standalone build's.
The standalone build lets Coana find its components in the cache, which it fills with the environment Coana then runs in.
a4c3b56 to
f2b07e4
Compare


Heads up, reviewer
This PR changes socket facts SBOM generation to use coana.
LLM Description written by Claude Code:claude-opus-5-5
Socket facts for Gradle, Maven, sbt and .NET builds are generated by Coana's
generate-socket-facts, one run per build root, instead of socket-cli's own build-tool scripts (deleted in #1727). With--dynamic-sbom-inference, reachability andsocket fixthen read the state each root's run kept, so reachability analyses each JVM project on the classpath its build resolved.Merges with the stack. The Coana release it needs is pinned on v1.x since #1762.
What changes for users
socket manifest gradle|kotlin|scala|maven|dotnet,manifest auto,--auto-manifest,--dynamic-sbom-inferenceand its setup wizard go through Coana, so they download it (network access and a Socket API token) unlessSOCKET_CLI_COANA_LOCAL_PATHnames one.--reach-versionand--fix-versionalso select the Coana that generates facts, which must be the pinned version or newer.--ignore-unresolvedno longer lets through a build whose resolution didn't run, or a failure that names no project.socket fixresolves each changed build again with the settings it was generated with, and restores its files when an upgrade didn't take.--dynamic-sbom-inferencebuilds each POM by its own file, so it ignores a--fileinmavenOpts, with a warning.Implementation
runManifestFactssends Coana one request per build root, with the hints its failure report names remedies from.--socket-facts-sidecar.Stack
Changelog
In
CHANGELOG.mdunder[Unreleased]:Added
Changed
--reach-versionand--fix-versionalso select the Coana that generates Socket facts, which must be the pinned version or newer.--dynamic-sbom-inference, reachability analyzes each JVM project on the classpath its build resolved, andsocket fixrestores a build's files when an upgrade does not take.--ignore-unresolvedno longer lets through a build whose resolution did not run, or a failure that names no project.--dynamic-sbom-inferencebuilds each POM by its own file, so it ignores a--fileinmavenOpts, with a warning.🤖 Generated with Claude Code